import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * This class makes reference to the Laser of the motherShip when she will shoot the killer laser.
 * 
 * @author (Arturo Aaron Rios Obregon) 
 * @version (25 june 2013)
 */
public class IniLaser extends Bala
{
    private GreenfootImage [] images;
    private int numImage;
    private SimpleTimer cTimer;
    
    /**
     * Constructor.
     */
    public IniLaser()
    {
        super(0);
        images = new GreenfootImage[4];
        images[0] = new GreenfootImage("iniLaser.png");
        images[1] = new GreenfootImage("iniLaserAma.png");
        images[2] = new GreenfootImage("iniLaserAzul.png");
        images[3] = new GreenfootImage("iniLaserVerde.png");
        numImage=0;
        setImage(images[0]);  
        cTimer = new SimpleTimer();
        cTimer.mark();
    }
    
    /**
     * change images and eliminate.
     */
    public void act() 
    {
        imagenes();
        elimina();
    }    
    
    /**
     * Eliminate the laser after certain time.
     */
    public void elimina()
    {
        if(cTimer.millisElapsed()/1000>4)
            getWorld().removeObject(this);
    }
    
    /**
     * change the images for the laser.
     */
    public void imagenes()
    {                
        numImage+=1;
        numImage=numImage%4;
        setImage(images[numImage]);
    }
}
